package com.inossem.warehousestorage_inossem.request.outStorage;

import android.content.Context;

import com.google.gson.Gson;
import com.inossem.warehousestorage_inossem.bean.outStorage.OutStoragePickingBatchListBean;
import com.inossem.warehousestorage_inossem.constant.RequestConstant;
import com.inossem.warehousestorage_inossem.listener.GsonBeanListener;
import com.inossem.warehousestorage_inossem.listener.StringRequestListener;
import com.inossem.warehousestorage_inossem.manage.RequestManage;
import com.inossem.warehousestorage_inossem.model.StringResponse;
import com.inossem.warehousestorage_inossem.request.Request;

import java.util.HashMap;
import java.util.Map;

/**
 * 作者：wsy on 2017/12/5 14:33
 * <p>
 * 邮箱：445979770@qq.com
 */

public class OutStorageAllocatingDefaultBatchRequest extends Request {
    private static final String MATERIEL_CODE = "materielCode";//物料编码

    private static final String NUMBER = "number";//数量

//    private static final String PICKING_CLASSIFY = "pickingClassify";//领料分类
//
//    private static final String USE_DEPARTMENT = "useDepartment"; //使用部门

    private static final String WERKS = "werks";//发出工厂

    private static final String INVENTORYA_DDRESS_CODE = "inventoryAddressCode";//发出库存地点

    public static String request(Context context, String materielCode, String number, String werks, String inventoryAddress, GsonBeanListener gsonBeanListener) {
        String tag;
        Map<String, String> params = new HashMap<>();
        params.put(MATERIEL_CODE, materielCode);
        params.put(NUMBER, number);
//        params.put(PICKING_CLASSIFY, pickingClassify);
//        params.put(USE_DEPARTMENT, useDepartment);
        params.put(WERKS, werks);
        params.put(INVENTORYA_DDRESS_CODE, inventoryAddress);
        String url = RequestManage.getUrl(context, RequestConstant.URL_OUT_STORAGE_ALLOCATING_DEFAULT_BATCH + RequestManage.mapEncodeToParams(params));
        tag = RequestManage.getHttpsGetWithLoading(context, url, new StringRequestListener() {
            @Override
            public void onSuccess(StringResponse stringRequestResponse) {
                Gson gson = new Gson();
                OutStoragePickingBatchListBean bean = gson.fromJson(stringRequestResponse.getResponseInfo(), OutStoragePickingBatchListBean.class);
                excuteJsonBean(context, bean, bean.getCode(), bean.getMsg(), gsonBeanListener);
            }
        });
        return tag;
    }
}
